<?php
namespace app\serveruser\validate;
use \app\manage\validate\BaseValidate;
/**
 * 用户的验证类
 * @author adv30 <adv30@126.com> 2017年6月12日14:53:24
 */
class User extends BaseValidate
{
    // 是否使用true基础的验证规则
    // protected $useBaseRules = false;
    protected $rule = [
        'id' => ['integer', 'gt' => '0'],
        'name' => ['alphaDash', 'length'=>'5,16'],
        'nickname' => ['chsDash', 'length'=>'5,16'],
        'login_password' => ['alphaDash', 'length'=>'8,16'],
        'old_login_password' => ['alphaDash', 'length'=>'8,16'],
        're_login_password' => ['alphaDash', 'length'=>'8,16', 'confirm'=>'login_password'],
        'pay_password' => ['integer', 'length'=>'6'],
        'old_pay_password' => ['integer', 'length'=>'6'],
        're_pay_password' => ['integer', 'length'=>'6', 'confirm'=>'pay_password'],
        'row_ids' => ['regex' => '^(\d)+(,\d+)*'],
        'row_group_ids' => ['regex' => '^(\d)+(,\d+)*'],
        'other_info' => ['regex' => '^{.*}$'],
        'ids' => ['regex' => '^\d+(,\d+)*$'],
        'role_id' => ['integer', 'gt' => '0'],
        'id_number' => ['regex'=>'^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$'],
        'front_img' => ['min'=>2],
        'back_img' => ['min'=>2],
        'real_name' => ['min'=>2],
        'status' => ['in'=>'1,2'],
        'auto_login_time' => ['integer', 'gt'=>0],
        'auto_login_token' => ['alphaNum', 'length' => '32'],
        'is_auto_login' => ['in'=>'0,1'],
        'is_add_no_user_counts' => ['in'=>'0,1'],
        'authen_status' => ['integer', 'in'=>'-1,0,1,2']
    ];
    protected $message = [
    ];
    protected $scene = [
        'login' => ['name', 'phone', 'login_password', 'token', 'is_auto_login'],
        'autoLogin' => ['name', 'phone', 'token', 'auto_login_time', 'auto_login_token'],
        'register' => ['name', 'nickname', 'phone', 'login_password', 'sex', 'other_info'],
        'info' => ['id', 'name', 'phone'],
        'perfect' => ['id', 'name', 'phone', 'other_info'],
        'passAudit' => ['id', 'name', 'phone'],
        'list' => ['page', 'list_rows'],
        'edit' => ['id', 'name', 'nickname', 'sex', 'phone', 'row_ids','row_group_ids','other_info'],
        'checkLoginPassword' => ['id', 'name', 'phone', 'login_password'],
        'editLoginPassword' => ['id', 'name', 'phone', 'login_password', 'old_login_password', 're_login_password'],
        'editSelfLoginPassword' => ['token', 'login_password', 'old_login_password', 're_login_password'],
        'editPayPassword' => ['id', 'name', 'phone', 'pay_password', 'old_pay_password', 're_pay_password'],
        'editSelfPayPassword' => ['token', 'pay_password', 'old_pay_password', 're_pay_password'],
        'initPayPassword' => ['id', 'name', 'phone', 'pay_password', 'login_password'],
        'forgetLoginPassword' => ['name', 'phone', 'phone_code', 'login_password'],
        'resetLoginPassword' => ['id','name', 'phone', 'login_password'],
        'resetUserLoginPassword' => ['id','name', 'phone', 'login_password', 're_login_password'],
        'resetAllLoginPassword' => ['id','name', 'phone', 'login_password', 're_login_password'],
        'resetUserPayPassword' => ['id','name', 'phone', 'pay_password', 're_pay_password'],
        'resetAllPayPassword' => ['id','name', 'phone', 'pay_password', 're_pay_password'],
        'infoByIds' => ['ids'],
        'logout' => ['token'],
        'giveRoles' => ['id', 'name', 'phone', 'role_id'],
        'removeUserRole' => ['id', 'name', 'phone', 'role_id'],
        'editSelfInfo' => ['nickname', 'sex'],
        'updateUserInfo' => ['nickname', 'sex', 'other_info'],
        'authentication' => ['token', 'id_number', 'front_img', 'back_img', 'real_name'],
        'changePhone' => ['phone'],
        'verifyAuthentication' => ['id','status'],
        'getAuthticationList' => ['page', 'list_rows', 'status'=>['in'=>'0,1,2']],
    ];
}
